package com.sqllog.messageMutipyThread;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class MessageConsumer implements Runnable{

    private MessageManagerResource resource;
    /**
     * canal 客户端的运行状态
     */
    private volatile boolean running = true;

    public void setRunning(boolean running) {
        this.running = running;
    }

    public MessageConsumer(MessageManagerResource resource) {
        this.resource = resource;
    }

    @Override
    public void run() {
        while (this.running) {
            try {
                resource.consumerMessage();
            } catch (InterruptedException e) {
                log.error("消息被中断" + e.getMessage());
                break;
            }
        }
    }
    
}